package action.client;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import component.RunCmdComponent;
import constants.Constants;
import utils.GameUtils;

/**
 * @Auther syc.
 * @Date 2016/11/21 15:02.
 */
public class ClientPathOpenAction extends AnAction {
    @Override
    public void actionPerformed(AnActionEvent anActionEvent) {
        Application application = ApplicationManager.getApplication();
        RunCmdComponent component = application.getComponent(RunCmdComponent.class);

        String path = GameUtils.getPropertyValue(anActionEvent, Constants.CLIENT_PATH_PRO_NAME);

        if (!GameUtils.isFileExist(path)) {
            return;
        }
        component.runCmd("cmd /c start " + path);
    }
}
